// websocket
package implement

import (
	"net/url"

	"awfan.cn/implement/attend"
	"awfan.cn/implement/member"
	"awfan.cn/implement/school"

	"github.com/gorilla/websocket"

	"net/http"

	"awfan.cn/implement/course"
	"awfan.cn/implement/place"
	"awfan.cn/implement/sign"

	"awfan.cn/implement/examp"
	"awfan.cn/implement/feedback"
	"awfan.cn/implement/logging"
	"awfan.cn/implement/test"
	"awfan.cn/implement/testrc"
	"gopkg.in/mgo.v2"
)

func init() {
	GET = make(map[string]func(*url.URL, http.ResponseWriter, *mgo.Database))
	PUT = make(map[string]func(*url.URL, http.ResponseWriter, []byte, *mgo.Database))
	POST = make(map[string]func(*url.URL, http.ResponseWriter, []byte, *mgo.Database))
	DEL = make(map[string]func(*url.URL, http.ResponseWriter, *mgo.Database))
	WSC = make(map[string]func(string, interface{}, *websocket.Conn, *mgo.Database))

	Clients = make(map[string]*websocket.Conn)
	append2("/member", "GET", member.Get)
	append("/member", "PUT", member.Put)
	append("/member", "POST", member.Post)
	append2("/member", "DELETE", member.Del)

	append2("/school", "GET", school.Get)
	append("/school", "PUT", school.Put)
	append("/school", "POST", school.Post)
	append2("/school", "DELETE", school.Del)

	append2("/place", "GET", place.Get)
	append("/place", "PUT", place.Put)
	append("/place", "POST", place.Post)
	append2("/place", "DELETE", place.Del)

	append2("/course", "GET", course.Get)
	append("/course", "PUT", course.Put)
	append("/course", "POST", course.Post)
	append2("/course", "DELETE", course.Del)

	append2("/sign", "GET", sign.Get)
	append("/sign", "PUT", sign.Put)
	append("/sign", "POST", sign.Post)
	append2("/sign", "DELETE", sign.Del)

	append2("/attend", "GET", attend.Get)
	append("/attend", "PUT", attend.Put)
	append("/attend", "POST", attend.Post)
	append2("/attend", "DELETE", attend.Del)

	append2("/logging", "GET", logging.Get)
	append("/logging", "POST", logging.Post)

	append("/feedback", "POST", feedback.Post)

	append2("/examp", "GET", examp.Get)
	append("/examp", "PUT", examp.Put)

	append2("/test", "GET", test.Get)
	append("/test", "PUT", test.Put)
	append("/test", "POST", test.Post)
	append2("/test", "DELETE", test.Del)

	append2("/test/record", "GET", testrc.Get)
	append("/test/record", "PUT", testrc.Put)
	append("/test/record", "POST", testrc.Post)

}
